<?php (!defined('IN_SYSTEM') || !defined('ADMIN_PRE')) && exit('Access Denied!');?>
{admintemplate header}
<div class="box">
 	<div class="heading">
		<h1>数据维护</h1>
	</div>
	<div class="main">
	<div class="htabs" id="tabs">
	<span <?php if($_REQUEST['f']=='recache')echo 'class="selected"'?>><a href="admin.php?m=data&f=recache">刷新缓存</a></span>
	<span <?php if($_REQUEST['f']=='recalendar')echo 'class="selected"'?>><a href="admin.php?m=data&f=recalendar">重建日历</a></span>
	<span <?php if($_REQUEST['f']=='dbop')echo 'class="selected"'?>><a href="admin.php?m=data&f=dbop" >数据表维护</a></span>
	<span <?php if($_REQUEST['f']=='bakout')echo 'class="selected"'?>><a href="admin.php?m=data&f=bakout">数据备份</a></span>
	<span <?php if($_REQUEST['f']=='baklist'||$f=='bakin')echo 'class="selected"'?>><a href="admin.php?m=data&f=baklist">数据还原</a></span>
	<span <?php if($_REQUEST['f']=='rebuildurl')echo 'class="selected"'?>><a href="admin.php?m=data&f=rebuildurl">重建别名</a></span>
	</ul>
	<script type="text/javascript">
	$('#tabs span').show(); 
	</script>
	</div>
	<table width="100%" cellspacing="0">
	<tr><td>
	
	<?php if ($f=='recache') { ?>
	<table>
		<tr>
			<td>某些系统设置需要刷新缓存才能生效。</td>
		</tr>
		<tr>
			<td>
			<input type="button" onclick="window.location='?m=data&f=recache&op=recache'" value="  刷新系统缓存  " class="button" />
			<input type="button" onclick="window.location='?m=data&f=recache&op=clearcachepage'" value="  清空缓存页面  " class="button" />
			</td>
		</tr>
	</table>
	<?php } elseif ($f=='recalendar') { ?>
	<table>
		<tr>
			<td>如果日历显示不准确，你可能需要重建日历。</td>
		</tr>
		<tr>
			<td><input type="button" onclick="window.location='?m=data&f=recalendar&op=exec'" value="  执 行  " class="button" /></td>
		</tr>
	</table>
	<?php } elseif ($f=='dbop') { ?>
	<table>
		<form name="form1" method="post" action="?m=data&f=dbop">
		<input type="hidden" value="yes" name="dosubmit" />
		<tr>
			<td>
			<?php
			echo '数据表：<br />';
			foreach ($db_tables as $table) {
				echo '<input type="checkbox" name="table[]" id="db_'.$table.'" class="checkbox" value="'.$table.'" /><label for="db_'.$table.'">'.$table.'</label>　';
			}
			echo '<br />操作：<br />';
			foreach ($db_op as $key => $val) {
				echo '<input type="checkbox" name="op[]" id="op_'.$key.'" class="checkbox" value="'.$key.'" checked="checked" /><label for="op_'.$key.'">'.$val.'</label>　';
			}
			?>
			</td>
		</tr>
		<tr>
			<td><input type="submit" value="  执 行  " class="button" /></td>
		</tr>
		</form>
	</table>
	<?php } elseif ($f=='bakout') { ?>

	<table cellspacing="0" class="datalist" width="100%">
	<form name="backup" method="get" target="do_backup" action="admin.php">
	<input type="hidden" name="m" value="data" />
	<input type="hidden" name="f" value="bakout" />
	<input type="hidden" value="yes" name="dosubmit" />
		<tr>
			<th width="50" class="firstcol">选择</th>
			<th>表名</th>
			<th width="100">记录数</th>
			<th width="100">大小</th>
			<th width="50">选择</th>
			<th>表名</th>
			<th width="100">记录数</th>
			<th width="100">大小</th>
		</tr>
		<tr align="center">
		<?php
		$count = count($sys_tb);	
		for ($i=0; $i<$count; $i++) {
			echo '
			<td '.(($i+1)%2==0?'style="border-left:1px solid #ccc"':'').'><input type="checkbox" class="checkbox" id="table_'.$i.'" name="baktables[]" value="'.$sys_tb[$i]['name'].'" /></td>
			<td align="left"><label for="table_'.$i.'">'.$sys_tb[$i]['name'].'</label></td>
			<td>'.$sys_tb[$i]['rows'].'</td>
			<td>'.$sys_tb[$i]['size'].'</td>
			';
			if ( ($i+1) % 2 == 0 ) echo "</tr><tr align=\"center\">\n";
		}
		?>
		</tr>
		<tr>
			<td align="center"><input type="checkbox" name="chkall" value="1" id="chkall1" class="checkbox" onclick="checkalltable(this)" /></td>
			<td colspan="7"><label for="chkall1">全选</label></td>
		</tr>
		<tr><td colspan="8" style="background:#EDF0F6;">数据备份选项：</td></tr>
		<tr><td width="100" align="right">当前数据库版本：</td><td colspan="7"><?php echo $_G['db']->version();?></td></tr>
		<tr>
			<td align="right">分卷大小：</td><td colspan="7"><input type="text" name="sizelimit" size="5" value="2048" /> K </td>
		</tr>
		<tr>
			<td colspan="8" align="center"><input type="submit" class="button" value="开始备份" /></td>
		</tr>
	</form>

		<tr><td colspan="8" style="background:#EDF0F6;">备份状态</td></tr>
		<tr>
			<td height="100" colspan="8">
			<iframe name="do_backup" frameborder="0" id="do_backup" width="100%" height="100%"></iframe>
			</td>
		</tr>
	</table>

	<?php } elseif ($f=='baklist') { ?>
	<form name="del" method="post" action="?m=data&f=bakdel">
		<table cellspacing="0" class="datalist" width="100%" id="list" class="list">
			<tr>
				<th width="50" class="firstcol">选择</th>
				<th>目录</th>
				<th width="200">备份时间</th>
				<th width="120">操作</th>
			</tr>
			<?php
			if ( !empty($result) ) {
				foreach ( $result as $row ) {
			?>
			<tr align="center" id="a_<?php echo $row['dir'];?>">
				<td><input type="checkbox" class="checkbox" name="id[]" value="<?php echo $row['dir'];?>" /></td>
				<td align="left"><?php echo 'cache/backup/'.$row['dir'];?></td>
				<td><?php echo $row['time'];?></td>
				<td><a href="?m=data&f=bakin&bakdir=<?php echo $row['dir'];?>">导入</a></td>
			</tr>
			<?php
				}
			?>
			<tr>
				<td align="center"><input type="checkbox" class="checkbox" name="chkall" onclick="check_all(this)" id="chkall" /></td>	
				<td colspan="3"><label for="chkall">全选</label> <input type="submit" value="删除" onclick="return confirm('一旦删除将不可恢复，确定要删除吗？');" class="button" /></td>
			</tr>
			<?php
			} else {
				echo '<tr><td colspan="5">没有备份记录...</td></tr>';
			}
			?>
		</table>
	</form>
	<?php } elseif ($f=='bakin') { ?>
	<table cellspacing="0" class="datalist" width="100%">
		<tr>
			<th class="firstcol" colspan="2" style="text-align:left;">备份详情</th>
		</tr>
		<tr>
			<td width="80" align="right">备份目录：</td><td><?php echo $result['dir'];?></td>
		</tr>
		<tr>
			<td align="right">备份时间：</td><td><?php echo $result['time'];?></td>
		</tr>
		<tr>
			<td align="right">分卷数目：</td><td><?php echo $result['count'];?> 卷</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
			<form name="bakin" method="get" target="do_bakin" action="admin.php">
			<input type="hidden" name="m" value="data" />
			<input type="hidden" name="f" value="bakin" />
			<input type="hidden" name="dosubmit" value="yes" />
			<input type="hidden" name="bakdir" value="<?php echo $bakdir;?>" />
			<input type="hidden" name="filepre" value="<?php echo $result['filepre'];?>" />
			<input type="hidden" name="count" value="<?php echo $result['count'];?>" />
			<input type="submit" class="button" value="开始导入" />
			<input type="button" class="button" value="取消返回" onclick="window.location='admin.php?m=data&f=baklist'" />
			</form>
			</td>
		</tr>
		<tr><td colspan="2" style="background:#EDF0F6;">还原状态</td></tr>
		<tr>
			<td height="100" colspan="2">
			<iframe name="do_bakin" frameborder="0" id="do_bakin" width="100%" height="100%"></iframe>
			</td>
		</tr>
	</table>
	<?php }elseif ($f=='rebuildurl'){ ?>
	<table>
		<tr>
			<td>如果你添加了新的链接别名，你需要重建链接别名。</td>
		</tr>
		<tr>
			<td><input type="button" onclick="window.location='?m=data&f=rebuildurl&op=exec'" value="  执 行  " class="button" /></td>
		</tr>
	</table>
	<?php }?>
	</td></tr>
	</table>

	</div>
</div>
{admintemplate footer}